bangkeapp.factory('interestsaccountService', ['$http', '$q', 'url', "userinfoService", "$ionicLoading",
function($http, $q, url, userinfoService, $ionicLoading) {
	
    var saveadvancerecharge = function(advancerecharge){
        var deferred = $q.defer();
        var promise = deferred.promise;
        var progress;
        var data = userinfoService.getNewData();
		data.body.advancerecharge = advancerecharge;
    		
		$http({    
            method: "JSONP",    
            url: url + "/advancerecharge/saveOrUpdate?callback=JSON_CALLBACK",  
            params: {
				"body": angular.toJson(data)
			}
		}).success(function(response) {
			var result = response;
			progress = "正确";
			deferred.notify(progress);
			deferred.resolve(result);
		})
		.error(function(error) {
			deferred.reject(error);
		});
		return promise;
   	}
    var queryrechargeinfo = function(advancerecharge, page, pagesize){
        var deferred = $q.defer();
        var promise = deferred.promise;
        var progress;
        var data = userinfoService.getNewData();
        data.body.page = page;
		data.body.pagesize = pagesize;
		data.body.advancerecharge = advancerecharge;
    		
		$http({    
            method: "JSONP",    
            url: url + "/advancerecharge/queryRechargeInfo?callback=JSON_CALLBACK",  
            params: {
				"body": angular.toJson(data)
			}
		}).success(function(response) {
			var result = response;
			progress = "正确";
			deferred.notify(progress);
			deferred.resolve(result);
		})
		.error(function(error) {
			deferred.reject(error);
		});
		return promise;
   	}
    
    return {
        saveadvancerecharge : saveadvancerecharge, // 红包积分充值
        queryrechargeinfo : queryrechargeinfo, // 充值进度查询
   	}
}
]);